Merged
Conversation
…d on each other This lets us set two parameters like alpha and beta without worrying about an assert panic. For example, if we require alpha < beta and beta defaults to 0.9, then we cannot set alpha to 0.91 even if we plan on later setting beta to 0.95. Rather than check if alpha > beta's default and branching, we can just set them both at the same time.
These should match the mut self -> Self pattern we use everywhere else
This makes Box<dyn T>'s easier to work with in multithreaded environments
…d unbounded intervals Previously, converting (Some(Float::NEG_INFINITY), Some(Float::INFINITY)) to a Bound with Into would create a Bound::LowerAndUpperBound, which is not correct and could cause issues in transforms. This also makes it okay for users to mix and match Nones and infinities.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #82 +/- ##
==========================================
+ Coverage 86.94% 88.10% +1.15%
==========================================
Files 32 32
Lines 5969 6137 +168
==========================================
+ Hits 5190 5407 +217
+ Misses 779 730 -49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #82 will not alter performanceComparing Summary
|
While this line search is currently unused by the provided algorithms, these are useful to have in the event someone wants to build an algorithm which uses it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactorings to the configuration and trait implementations for optimization algorithms in the codebase. The main changes include the addition of new builder methods for setting multiple parameters at once, enhanced parameter validation, expanded unit testing for configuration methods, and trait updates to improve thread safety and composability.
Configuration builder and validation improvements
NelderMeadConfig(with_alpha_beta),HagerZhangLineSearch(with_delta_sigma), andMoreThuenteLineSearch(with_c1_c2), with strict validation and documentation for panics on invalid input. [1] [2] [3]Swarmto consume and returnSelfinstead of using mutable references, improving ergonomics and composability for swarm configuration.Expanded unit test coverage
BacktrackingLineSearch,HagerZhangLineSearch, andMoreThuenteLineSearch, including checks for correct value assignment and expected panics on invalid input. [1] [2] [3] [4]Trait enhancements for thread safety
AbortSignal,Algorithm,BoundLike,LineSearch, andTransform) to requireSendandSync, ensuring that algorithm components are safe for concurrent and multi-threaded execution. [1] [2] [3] [4] [5]Documentation and minor algorithmic clarifications
Minor refactoring
Boundconversion logic for(Option<Float>, Option<Float>), removing unnecessary ordering and directly mapping to bound variants.SwarmStatusand other modules.Let me know if you'd like a deeper dive into any of these changes or want to discuss how the new builder methods and trait bounds affect usage patterns!This pull request introduces new convenience methods to set multiple related parameters at once in several optimization algorithm configuration structs, clarifies documentation and panic conditions, and improves thread safety and API consistency across traits and structs. The most significant changes are grouped below.
New convenience methods for configuration
with_alpha_betatoNelderMeadConfigto set both the reflection and expansion coefficients simultaneously, with appropriate assertions.with_delta_sigmatoHagerZhangLineSearchto set both Armijo and Wolfe condition parameters at once, with validation.with_c1_c2toMoreThuenteLineSearchto set both control parameters for Armijo and Wolfe conditions simultaneously, with validation.API consistency and ergonomics
Swarmto take and returnSelfby value instead of mutable references, improving method chaining and consistency.Thread safety improvements
Send + Syncbounds to core traits such asAbortSignal,Algorithm,BoundLike,LineSearch, andTransform, ensuring these types can be safely shared across threads. [1] [2] [3] [4] [5]Documentation and validation clarity
HagerZhangLineSearchandMoreThuenteLineSearchto accurately reflect the mathematical requirements. [1] [2]Minor improvements
SwarmStatusfield documentation for clarity.From<(Option<Float>, Option<Float>)> for Boundfor clarity and correctness in bound construction.